#! /bin/sh

name=libiconv
version=1.18
revision=1
tarball_url="https://ftp.gnu.org/gnu/libiconv/libiconv-${version}.tar.gz"
tarball_blake2b="374e7a7299d4814d372d8e63246c11f403f9fc990be5b129d016b92a875d2f8e9697ef4ef5cbd2e7b7fc97dff427c6b8abf6a99da792fcabd6fc36af38cd4723"
imagedeps="binutils"
hostdeps="gcc pkg-config"
deps="mlibc libgcc libstdc++ libatomic"

prepare() {
    autotools_recursive_regen
}

configure() {
    autotools_configure
}

build() {
    make -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" make install

    # Move documentation into a sub-directory
    mkdir -p "${dest_dir}${prefix}/share/doc/libiconv"
    mv "${dest_dir}${prefix}/share/doc"/*.html "${dest_dir}${prefix}/share/doc/libiconv/"

    mkdir -p "${dest_dir}${prefix}/lib/pkgconfig"
    cat <<EOF >"${dest_dir}${prefix}/lib/pkgconfig/iconv.pc"
prefix=${prefix}
exec_prefix=\${prefix}
bindir=\${exec_prefix}/bin
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: iconv
Description: libiconv library
Version: ${version}
Libs: -L\${libdir} -liconv
Cflags: -I\${includedir}
EOF

    post_package_strip
}
